package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.AssociationTypes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.yxuan.springboot.model.AssociationTypes;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * 
 * @author zchao
 *   AssociationTypes控制器
 * @date 2023-09-25 21:29:24
 */
@Controller
@Api(tags = "文章类型")
@RequestMapping(value = "/associationtypes", method = {RequestMethod.POST,RequestMethod.GET})
public class AssociationTypesController extends BaseController<AssociationTypes>{
    @ApiOperation(value = "根据条件删除数据", notes = "根据条件删除数据",httpMethod = "DELETE")
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(AssociationTypes t){
        try {
            return baseService.remove(t);
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

    /**
     * 添加
     */
    @ApiOperation(value = "添加数据", notes = "添加数据",httpMethod = "POST")
    @RequestMapping("/saveT")
    @ResponseBody
    public String saveT(@RequestBody AssociationTypes entity) throws IOException {
        try {
            return baseService.save(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改数据", notes = "修改数据",httpMethod = "PUT")
    @RequestMapping("/updT")
    @ResponseBody
    public String updT(@RequestBody AssociationTypes entity) throws Exception {
        try {
            return baseService.upd(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }
    }

}
